<?php

namespace Wilead\CoreBundle\Form\Transformer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

use Symfony\Component\Form\DataTransformerInterface;

/**
 * Description of PointToStringTransformer
 *
 * @author jack
 */
class PointToStringTransformer implements DataTransformerInterface {

    public function reverseTransform($string) {
        if ($string === NULL) {
            return '';
        }

        $point = explode(',', $string);

        return new \CrEOF\Spatial\PHP\Types\Geography\Point($point[0], $point[1]);
    }

    public function transform($point) {
        if ($point === NULL) {
            return '';
        }

        return implode(',', $point);
    }

}

?>
